package cn.deepmax.spring.cloud.common.config.jpa;

import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.data.auditing.DateTimeProvider;

import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.time.temporal.TemporalAccessor;
import java.util.Optional;


public class JpaConfig {

    @Bean
    @Qualifier("auditingDateTimeProvider")
    public DateTimeProvider auditingDateTimeProvider(){
        return new DateTimeProvider() {
            @Override
            public Optional<TemporalAccessor> getNow() {
                LocalDateTime now = LocalDateTime.now(ZoneOffset.of("+8"));
                return Optional.of(now);
            }
        };
    }
}
